package com.hongyue.zuoTi1;

import java.math.BigDecimal;
import java.util.ArrayList;

import static java.math.BigDecimal.ROUND_HALF_UP;

/*
		张三,男,20,79.5
		李四,女,21,80.2
		王五,男,22,77.9
		周六,男,20,55.8
		赵七,女,21,99.9
 */
public class Demo {
    public static void main(String[] args) {
        ArrayList<XueSheng> xs = new ArrayList<>();
        xs.add(new XueSheng("张三", "男", "20", "79.5"));
        xs.add(new XueSheng("李四", "女", "21", "80.2"));
        xs.add(new XueSheng("王五", "男", "22", "77.9"));
        xs.add(new XueSheng("周六", "男", "20", "55.8"));
        xs.add(new XueSheng("赵七", "女", "21", "99.9"));
        BigDecimal a = new BigDecimal(0);
        BigDecimal b = new BigDecimal(xs.size());
        for (int i = 0; i < xs.size(); i++) {
            XueSheng c = xs.get(i);
            String e = c.getFenShu();
            BigDecimal q = new BigDecimal(e);
            a = a.add(q);
        }
        BigDecimal y = a.divide(b, 2, ROUND_HALF_UP);
        System.out.println(y);
    }
}
